package com.ianmoone.juc;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

public class CallableTest {
	
	public static void main(String[] args) {
		CallableThread callableThread = new CallableThread();
		ExecutorService es = Executors.newCachedThreadPool();
		Future<Integer> submit = es.submit(callableThread);
		FutureTask<Integer> future = new FutureTask<>(callableThread);
		try {
			System.out.println(submit.get());
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		es.shutdown();
	}
}

class CallableThread implements Callable<Integer>{

	@Override
	public Integer call() throws Exception {
		int a = 1+3;
		return a;
	}
	
}
